There are conventional techniques for calculating the attitude of a device using a magnetic sensor. For example, by detecting the direction of a magnetic field using a magnetic sensor, it is possible to calculate the attitude of a device with respect to the direction of the magnetic field.
Where the attitude of a device is calculated using a sensor, such as a magnetic sensor, which gives an output by detecting a value that is dependent on the attitude, the ability to precisely calculate the attitude is required.
Thus, the present disclosure provides a storage medium having information processing program stored thereon, an information processing device, an information processing system, and an attitude calculation method capable of precisely calculating the attitude of a device.
(1)
This application describes a non-transitory computer-readable storage medium storing an information processing program to be executed by a computer of an information processing device for calculating an attitude of an input unit having a magnetic sensor. The information processing program causes the computer to execute the following.
The computer repeatedly obtains detected magnetic vectors detected by the magnetic sensor. The computer repeatedly estimates a center position of a spherical body having a curved surface which is estimated based on end point positions of the detected magnetic vectors. The computer calculates the attitude of the input unit based on a direction vector representing a direction from the center position to the end point position of the detected magnetic vector.
The computer calculates the attitude while relatively decreasing an influence of a newly-obtained detected magnetic vector as the end point position of the newly-obtained detected magnetic vector is farther away from the end point positions of the detected magnetic vectors used for the estimation of the center position.
With configuration (1) above, if the end point position of a newly-obtained detected magnetic vector is relatively far away from the end point positions of the detected magnetic vectors obtained thus far, the information processing device calculates the attitude of the input unit while relatively decreasing the influence of the newly-obtained detected magnetic vector. Then, it is possible to reduce the possibility that the attitude is calculated based on an inaccurate direction vector in such a case as described above. Thus, it is possible to precisely calculate the attitude of the input unit.
With configuration (1) above, if the end point position of the newly-obtained detected magnetic vector is relatively close to the end point positions of the detected magnetic vectors obtained thus far, the information processing device calculates the attitude of the input unit while relatively increasing the influence of the newly-obtained detected magnetic vector. Then, even when the estimated center position has not sufficiently converged to the vicinity of the actual center position, it is possible to calculate the attitude using a direction vector which is considered accurate to some degree. That is, with the configuration above, even if the estimated center position has not sufficiently converged to the vicinity of the actual center position, it is possible to calculate the attitude using a direction vector, whereby the calculation will not result in an inaccurate attitude. Therefore, with configuration (1) above, it is possible to calculate the attitude early.
(2)
The computer may calculate the attitude while relatively decreasing the influence of the newly-obtained detected magnetic vector as a difference between a length from the center position to the end point position of the newly-obtained detected magnetic vector and a length determined based on lengths from the center position to the end point positions of the detected magnetic vectors used for the estimation of the center position is larger.
With configuration (2) above, the information processing device calculates the attitude while relatively decreasing the influence of the newly-obtained detected magnetic vector depending on the difference between the two lengths. Then, it is possible to adjust the influence of the newly-obtained detected magnetic vector on the attitude calculation while taking into account the accuracy of the center position.
(3)
The computer may update the center position using the newly-obtained detected magnetic vector, independent of a relationship between the end point position of the newly-obtained detected magnetic vector and the end point positions of the detected magnetic vectors used for the estimation of the center position.
With configuration (3) above, even if the attitude is not calculated, the center position is updated. Therefore, since the center position can be updated to a more accurate position even when the attitude is not calculated, it is thereafter possible to more precisely calculate the attitude.
(4)
The computer may correct the attitude of the input unit, which is calculated by a different method other than a method of using the detected magnetic vectors, based on the direction vector.
With configuration (4) above, since the attitude of the input unit is calculated by the different method, it is possible to calculate the attitude even when it is not possible to accurately calculate the attitude by the method of using a magnetic sensor, for example.
(5)
The information processing program may cause the computer to further execute: setting a degree of correction based on a difference between a length from the center position to the end point position of the newly-obtained detected magnetic vector and a length determined based on lengths from the center position to the end point positions of the detected magnetic vectors used for the estimation of the center position. Then, the computer varies an amount of correction using the direction vector depending on the degree of correction.
With configuration (5) above, the information processing device sets the degree of correction based on the difference between the two lengths. Then, it is possible to set a degree of correction taking into account the accuracy of the center position, and it is possible to adjust the influence of the newly-obtained detected magnetic vector on the attitude calculation while taking into account the accuracy of the center position.
(6)
The computer may calculate the center position using a condition regarding a length from the center position to the end point position of the detected magnetic vector.
With configuration (6) above, using the length as a condition (e.g., using a condition that the lengths come close to being an equal length), it is possible to precisely calculate the center position of the spherical body.
(7)
When a detected magnetic vector is newly obtained, the computer may update the center position so that lengths from the center position to the end points of the detected magnetic vectors used for the estimation of the center position are each brought closer to an average between these lengths.
With configuration (7) above, it is possible to precisely calculate the center position of the spherical body.
(8)
Each time a detected magnetic vector is newly obtained, the computer may update the center position using at least the newly-obtained detected magnetic vector. Then, each time a detected magnetic vector is newly obtained, the computer calculates the attitude of the input unit based on the direction vector determined based on the updated center position.
With configuration (8) above, since the center position is updated each time a detected magnetic vector is obtained, it is possible to calculate a more accurate center position based on the latest detected magnetic vector, and it is therefore possible to calculate a more accurate attitude.
(9)
The computer may calculate the attitude using the direction vector at least on a condition that an area determined based on the end point positions of the obtained detected magnetic vectors has become larger than a predetermined reference.
With configuration (9) above, the attitude is not calculated when it is difficult to calculate an accurate center position because the directions of the obtained detected magnetic vectors are too unevenly distributed. That is, it is possible to reduce the possibility that an inaccurate attitude is calculated using an inaccurate center position, and it is therefore possible to more precisely calculate the center position.
(10)
The computer may calculate the attitude while relatively decreasing the influence of the newly-obtained detected magnetic vector as an amount of change of the center position before and after an update is larger.
With configuration (10) above, when the amount of change (the amount of movement) of the center position is large, the influence of the newly-obtained detected magnetic vector on the attitude calculation is decreased. Now, when the amount of change of the center position is large, it is believed that there is a possibility that the center position is inaccurate. Therefore, with configuration (10) above, it is possible to reduce the possibility that an inaccurate attitude is calculated using a center position that may possibly be inaccurate, and it is therefore possible to precisely calculate the attitude.
(11)
The computer may calculate the attitude while relatively decreasing the influence of the newly-obtained detected magnetic vector as dispersion between lengths from a current center position to the end point positions of the detected magnetic vectors used for the estimation of the center position is larger.
With configuration (11) above, when the dispersion is large, the influence of the newly-obtained detected magnetic vector on the attitude calculation is decreased. Now, when the dispersion is large, it is believed that there is a possibility that the center position is inaccurate. Therefore, with configuration (11) above, it is possible to reduce the possibility that an inaccurate attitude is calculated using a center position that may possibly be inaccurate, and it is therefore possible to precisely calculate the attitude.
(12)
The information processing program may cause the computer to further execute: setting a detected magnetic vector which is detected when a predetermined operation is performed by a user as a reference magnetic vector. Then, the computer calculates the attitude while relatively decreasing the influence of the newly-obtained detected magnetic vector as a direction from the center position to the newly-obtained detected magnetic vector is farther away from a direction from the center position to the reference magnetic vector.
With configuration (12) above, the influence of the newly-obtained detected magnetic vector on the attitude calculation is decreased as the two directions are farther away from each other. Now, when the two directions are far away from each other, there is a possibility that the magnetic field around the input unit has changed, whereby it is not possible to accurately calculate the attitude. In contrast, with configuration (12) above, it is possible to reduce the possibility that an inaccurate attitude is obtained due to a change to the magnetic field around the input unit, and it is therefore possible to precisely calculate the attitude.
(13)
The information processing program may cause the computer to further execute: storing the detected magnetic vectors in a storage unit where each detected magnetic vector is classified based on a direction from a reference position, which is determined based on the detected magnetic vector, to the end point position of the detected magnetic vector. Then, the computer estimates a center position of a spherical body having a curved surface which is estimated based on the end point positions of detected magnetic vectors obtained by extracting, from among the classified detected magnetic vectors, at least one detected magnetic vector for each class.
With configuration (13) above, each detected magnetic vector is classified based on the direction from the reference position to the end point of the detected magnetic vector. Now, by using direction vectors extending in various directions, it is more likely that the estimated center position is calculated more accurately. That is, by classifying each detected magnetic vector based on the direction from the reference position to the end point of the detected magnetic vector, as in configuration (13) above, it is possible to estimate the center position using detected magnetic vectors extending in various directions. Thus, it is possible to more accurately estimate the center position, and therefore to precisely calculate the attitude of the input unit.
(14)
This application also describes another example information processing program to be executed by a computer of an information processing device for calculating an attitude of an input unit having a sensor for detecting a value which varies depending on the attitude of the input unit. The information processing program causes the computer to function as an obtaining mechanism, a center estimating mechanism, and a attitude calculating mechanism.
The obtaining mechanism obtains detected vectors detected by the sensor. The center estimating mechanism estimates a center position of a spherical body having a curved surface which is estimated based on end point positions of the detected vectors. The attitude calculating mechanism calculates the attitude of the input unit based on a direction vector representing a direction from the center position to the end point position of the detected vector. If an end point position of a newly-obtained detected vector is farther away from the end point positions of the detected vectors used for the estimation of the center position than a predetermined reference, the attitude calculating mechanism calculates the attitude while relatively decreasing an influence of the newly-obtained detected vector.
With configuration (14) above, where the attitude of the input unit is calculated using a sensor for detecting a value which varies depending the attitude of the input unit, similar advantageous effects to those of configuration (1) above can be obtained.
Note that the present specification discloses an information processing device and an information processing system including various units that are equivalent to various units implemented by executing the information processing program recited in configurations (1) to (14) above, and also discloses an attitude calculation method to be carried out in configurations (1) to (14).
With the storage medium having information processing program stored thereon, the information processing device, the information processing system and the attitude calculation method, the attitude of the input unit is calculated while relatively decreasing the influence of a newly-obtained detected magnetic vector, depending on the degree by which the end point position of the newly-obtained detected magnetic vector is relatively far away from the end point positions of the detected magnetic vectors obtained thus far. Thus, it is possible to precisely calculate the attitude of the input unit.
These and other objects, features, aspects and advantages will become more apparent from the following detailed description when taken in conjunction with the accompanying drawings.